package com.moss.cloud.auth.biz.message;


import com.moss.cloud.auth.biz.service.ISysMenuService;
import com.moss.cloud.common.core.constant.MsgGroup;
import com.moss.cloud.common.core.constant.MsgTopic;
import com.moss.cloud.common.core.model.dto.MessageDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 消息管理-监听 集群模式 MessageModel.CLUSTERING
 *
 * @author 瑾年
 * @date 2020/05/15
 */
@Slf4j
@Component
@RocketMQMessageListener(consumerGroup = MsgGroup.MOSS_CLOUD_AUYH, topic = MsgTopic.BASE_RESOURCE_CHANGE, messageModel = MessageModel.CLUSTERING)
public class ResourceChangeMessageListener implements RocketMQListener<MessageDTO> {
    private final ISysMenuService sysMenuService;
    public ResourceChangeMessageListener(ISysMenuService sysMenuService){
        this.sysMenuService = sysMenuService;
    }

    /**
     * 监听资源变更MQ消息
     *
     * @param messageDTO
     * @return void
     * @author 瑾年
     * @date 2023年11月21日
     */
    @Override
    public void onMessage(MessageDTO messageDTO) {
        log.info("资源变更消费者获取消息:{}", messageDTO.toString());
        sysMenuService.loadSysMenu();
    }
}
